const path = require('path')
const HtmlWebpackPlugin = require('html-webpack-plugin')
const {CleanWebpackPlugin}= require('clean-webpack-plugin')

module.exports = (env, argv) => {
  const config =  {
    mode: "development",
    entry: "./src/index.js",
    output: {
      filename: "bundle.js",
      path: path.join(__dirname, "dist")
    },
    devtool: 'eval',
    plugins: [
      new HtmlWebpackPlugin({
        title: '标题'
      })
    ]
  }
  if(env === 'production'){
    config.mode = env
    config.devtool = false
    config.plugins.push(new CleanWebpackPlugin())
  }
  return config
}